<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt"%>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${tabTitle}</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<div id="pageInTab" class="pageInTab">
				<form id="ins_cfg_info_edit_form_webank">
					<div class="fieldset1 tabel_col clearFix">
						<div class="fieldBox col_50">
							<div class="label">机构名称</div>
							<div class="field">
								<span name="fundRasInsNm" id="fundRasInsNm">${fundRasInsNm}</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">客户名称</div>
							<div class="field">
								<span >${cstNm}</span>
							</div>
						</div>
                        <div class="fieldBox col_50">
                            <div class="label">身份证</div>
                            <div class="field">
                                <span >${certNo}</span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">月收入(元)</div>
                            <div class="field">
                                <input name="monthInc" id="monthInc" type="text" class="ui-textbox" value="<fmt:formatNumber type="number" value="${monthInc}"  pattern=".00"/>" validate="{number:true}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
						<div class="fieldBox col_50">
							<div class="label">开户银行</div>
							<div class="field">
                                <select name="bkCd" id="bkCd" value="${bkCd}" validate="{required:true}">
                                    <c:if test="${bkCd == null || bkCd == ''}">
                                        <option value="" selected="selected">--请选择--</option>
                                    </c:if>
                                    <c:if test="${bkCd != null && bkCd != ''}">
                                        <option value="">--请选择--</option>
                                    </c:if>
                                    <c:forEach items="${bankList}" var="item">
                                        <c:if test="${item.key == bkCd}">
                                            <option value="${item.key}" selected="selected">${item.value}</option>
                                        </c:if>
                                        <c:if test="${item.key != bkCd}">
                                            <option value="${item.key}">${item.value}</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
								<span class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">银行账号</div>
							<div class="field">
								<input name="accNo" id="accNo" type="text" class="ui-textbox" value="${accNo}" validate="{number:true, maxlength:22, minlength:15}">
								<span class="requiredSymbol">*</span>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">预留手机号</div>
							<div class="field">
								<input name="mp" id="mp" type="text" class="ui-textbox" value="${mp}" validate="{number:true, maxlength:11, minlength:11}">
								<span class="requiredSymbol">*</span>
							</div>
						</div>
                        <%--<div class="fieldBox col_50">
                            <div class="label">开户行号</div>
                            <div class="field">
                                <input name="bkNo" id="bkNo" type="text" class="ui-textbox" value="${bkNo}" validate="{number:true, maxlength:15, minlength:12}">
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>--%>
                        <div class="fieldBox col_50">
                            <div class="label">区域</div>
                            <div class="field">
                                <jsp:include page="../../system/sysRegion/region.jsp" flush="true">
                                    <jsp:param name="regionShowLvl"  value="2"/>
                                </jsp:include>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">纳税居民声明</div>
                            <div class="field">
                                <select name="taxResDecCd" id="taxResDecCd" value="${taxResDecCd}" >
                                    <c:if test="${taxResDecCd == null || taxResDecCd == ''}">
                                        <option value="" selected="selected">--请选择--</option>
                                    </c:if>
                                    <c:if test="${taxResDecCd != null && taxResDecCd != ''}">
                                        <option value="">--请选择--</option>
                                    </c:if>
                                    <c:forEach items="${taxResDecCdList}" var="item">
                                        <c:if test="${item.key == taxResDecCd}">
                                            <option value="${item.key}" selected="selected">${item.value}</option>
                                        </c:if>
                                        <c:if test="${item.key != taxResDecCd}">
                                            <option value="${item.key}">${item.value}</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <span class="requiredSymbol">*</span>
                            </div>
                        </div>
                        <div class="fieldBox col_50">
                            <div class="label">微众抵押合同模板</div>
                            <div class="field">
                                <span class="btns"><span class="sq-button sq-button-round" onclick="downloadSplFileByUrl();">打包下载</span></span>
                            </div>
                        </div>
                        <div class="fieldBox col_100_auto">
                            <div id="hint" style="text-align: center">
                                <span style="color: #20099b">友情提示：资方审核通过后，从微众抵押合同模板处下载附件进行签订。</span>
                            </div>
                        </div>
                        <!-- hide data -->
						<div class="fieldBox col_100" style="display: none;">
							<div class="field">
								<input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjId}">
								<input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                                <input name="insCode" id="insCode" type="text" class="ui-textbox" value="${insCode}">
                                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
								<input name="cstAccInfoId" id="cstAccInfoId" type="text" class="ui-textbox" value="${cstAccInfoId}">
								<input name="fundRasInsId" id=fundRasInsId type="text" class="ui-textbox" value="${fundRasInsId}">
							</div>
						</div>
					</div>
	                <div id="saveInsCfgDiv" class="btnsBox">
	                    <sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addPrjBscInfo" pInstId="${pInstId}">
	                        <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存</span>
	                    </sys:FlowFrmAth>
                	</div>
                </form>
			</div>
		</div>
	</div>

<script type="text/javascript">
var certNo = '${certNo}';
var detailFlag = '${detailFlag}';
// REQ-7008 信审初审节点 客户经理 可修改字段
var fromCAFlag = '${fromCAFlag}';
var fromCMFlag = '${fromCMFlag}';
$(function () {
	initData();
});

function initData() {
    $("#ins_cfg_info_edit_form_webank").ligerForm({
        validate: true
    });
	disabledInput();
    enableFields();
    //设置省、市
    setRgnProvCdUpdataValue('${rgnPrCd}');
    setRgnCityCdUpdataValue('${rgnCyCd}');
}

 function disabledInput() {
    //流程附件页面
	if(detailFlag == "true") {
		liger.get("bkCd").setDisabled();
		liger.get("accNo").setDisabled();
		liger.get("mp").setDisabled();
		/*liger.get("bkNo").setDisabled();*/
		liger.get("monthInc").setDisabled();
		liger.get("taxResDecCd").setDisabled();
        liger.get("rgnProvCd").setDisabled();
        liger.get("rgnCityCd").setDisabled();
        $("#saveInsCfgDiv").hide();
	}
}

function enableFields() {
    if (null != fromCAFlag && "true" == fromCAFlag) {
        liger.get("monthInc").setEnabled();
        liger.get("rgnProvCd").setEnabled();
        liger.get("rgnCityCd").setEnabled();
        $("#saveInsCfgDiv").show();
    }
    if (null != fromCMFlag && "true" == fromCMFlag) {
        liger.get("monthInc").setEnabled();
        liger.get("rgnProvCd").setEnabled();
        liger.get("rgnCityCd").setEnabled();
        $("#saveInsCfgDiv").show();
    }
}


// 保存项目客户信息，后面弹出准入验证的资料确认页
function saveInfo() {
	var ligerForm = liger.get("ins_cfg_info_edit_form_webank");
    if (!ligerForm.valid()) {
        top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
        return false; //验证不通过，不执行以下代码
    }        

	if(!$("#monthInc").val()){
        top.$.ligerDialog.SQalert({content: "请填写月收入！", SQ_type: "error"});
        return false;
    }
     if(!$("#bkCd").val()){
        top.$.ligerDialog.SQalert({content: "请选择开户银行！", SQ_type: "error"});
        return false;
    }
    if(!$("#accNo").val()){
        top.$.ligerDialog.SQalert({content: "请填写银行账号！", SQ_type: "error"});
        return false;
    }
    if(!$("#mp").val()){
        top.$.ligerDialog.SQalert({content: "请填写预留手机号码！", SQ_type: "error"});
        return false;
    }
    /*if(!$("#bkNo").val()){
        top.$.ligerDialog.SQalert({content: "请填写开户行号！", SQ_type: "error"});
        return false;
    }*/
    if(!getRgnProvCd()){
        top.$.ligerDialog.SQalert({content: "请选择区域-省！", SQ_type: "error"});
        return false;
    }
    if(!getRgnCityCd()){
        top.$.ligerDialog.SQalert({content: "请选择区域-市！", SQ_type: "error"});
        return false;
    }
    if(!$("#taxResDecCd").val()){
        top.$.ligerDialog.SQalert({content: "请选择纳税居民声明！", SQ_type: "error"});
        return false;
    }

    var data = ligerForm.getData();
    // data["bkNm"] = liger.get("bkCd").selectedText;
    data["cstAccInfoId"] = $("#cstAccInfoId").val();//项目id
    data["prjId"] = $("#prjId").val();//项目id
    data["cstId"] = $("#cstId").val();//客户id
    data["insCode"] = $("#insCode").val();//机构code
    data["fundRasInsId"] = $("#fundRasInsId").val();//机构
    data["certNo"] = certNo;//身份证号
    var index=document.getElementById("bkCd").selectedIndex;//获取当前选择项的索引.
    data["bkNm"] = document.getElementById("bkCd").options[index].text;//获取当前选择项的文本.
    data["bkCd"] = liger.get("bkCd").selectedValue;//开户银行
    /*data["bkNo"] = $("#bkNo").val();//开户行号*/
    data["accNo"] =  $("#accNo").val();//银行账号
    data["cstNm"] = $("#cstNm").val();//客户名称
    data["monthInc"] = $("#monthInc").val();//客户名称
    data["taxResDecCd"] = liger.get("taxResDecCd").selectedValue;//纳税居民申明
    data["rgnPrCd"] = getRgnProvCd();
    data["rgnCyCd"] = getRgnCityCd();

    data["mp"] = $("#mp").val(); //手机号
    var url = '<%=path%>/institution/webank/webankAddOrModifyPrjAccInfo.do';
    var wait_dialog;
    $.ajax({
        type: 'post',
        dataType: 'json',
        data: data,
        url: url,
        beforeSend: function () {
            wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
        },
        success: function (msg) {
            wait_dialog.close();
            if (msg.success == 1) {
            	//setData(msg.data);//设置数据
            	//mainData = msg.data;
            	disabledInput();
            	//setData();
				UIUtils.alertSuccessHold1(msg.info);
            } else {
                UIUtils.alertErrorHold1(msg.info);
            }
        }
    });
}

function uploadFileByUrl(_url,_name){
    if(SQ.regs.img.test(_name)){
        //SQ.imgPreview(_url);
        //SQ.imgPreview(_url, true);
        window.__ImgSrc = _url;
        window.__ImgTit = _name;
        window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
    }else{
        window.open(_url);
    }
}

function downloadSplFileByUrl() {
    var actoinURL = '<%=path%>/system/sysulfilesrec/zipDownloadById.do?';
    var form = $("<form>");
    $('body').append(form);
    form.attr('style','display:none');
    form.attr('target','');
    form.attr('method','post');
    form.attr('action',actoinURL);//下载文件的请求路径
    var input = $('<input>');
    input.attr('type','hidden');
    input.attr('name','ids');
    input.attr('value',JSON.stringify(${fileIds}));
    form.append(input);
    form.submit();
}

</script>

</body>
</html>